<script>
import api from '@/api'
import { Descriptions as YsDescriptions } from '@/components/YS'

export default {
  name: 'AdminLogDetail',
  components: {
    YsDescriptions
  },
  props: {
    id: {
      type: Number,
      default: 0
    }
  },
  data () {
    const _this = this
    return {
      params: {},
      descriptions: {
        title: '操作日志详情',
        fields: {
          admin_id: '管理员ID',
          content: '内容',
          create_time: '创建时间',
          id: 'ID',
          ip: 'IP',
          title: '标题',
          url: 'URL',
          useragent: 'UA',
          username: '用户名称'
        },
        data () {
          _this.params.id = _this.id || _this.$route.query.id
          return api.admin.log.detail(_this.params).then(response => {
            return Promise.resolve(response.data.data.row)
          }).catch(error => {
            return Promise.reject(error)
          })
        }
      }
    }
  },
  created () {
    this.params.id = this.id || this.$route.query.id
  },
  render () {
    const props = this.descriptions
    return <ys-descriptions { ...{ props } } ></ys-descriptions>
  }
}
</script>
